package com.cssl.controller;

import com.cssl.domain.DtsAddress;
import com.cssl.domain.dto.AddressDto;
import com.cssl.domain.dto.DtsAddressDto;
import com.cssl.openFeign.DtsAddressClient;

import com.cssl.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/useraddress")
public class DtsAddressController {
    @Autowired
    private DtsAddressClient addressClient;

    @PostMapping("/listAddress")
    public Result getAddressList(@RequestBody DtsAddressDto dtsAddressDto) {
        return addressClient.getAddressList(dtsAddressDto);
    }

    @PostMapping("/getUserAddress")
    public Result getUserAddress(){
        return addressClient.getUserAddress();
    }


    @PostMapping("/getNationwide")
    @ApiOperation(value = "获得全国的省,市,县")
    public Result getNationwide(@RequestBody AddressDto address){
        return addressClient.getNationwide(address);
    }

    @PostMapping("/getAllNationwide")
    @ApiOperation(value = "一次性获得全国的省,市,县")
    public Result getAllNationwide(){
        return addressClient.getAllNationwide();
    }

    @PostMapping("/addUserAddress")
    @ApiOperation(value = "新增用户地址")
    public Result addUserAddress(@RequestBody DtsAddress address){
        return addressClient.addUserAddress(address);
    }


    @PostMapping("/deleteUserAddress")
    @ApiOperation(value = "删除用户地址")
    public Result deleteUserAddress(@RequestBody DtsAddress address){
        return addressClient.deleteUserAddress(address);
    }


}
